home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Susp.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  701 b   |  21 lines  |  [TEXT/Moml]

  1. (* Susp -- support for lazy evaluation 1995-05-21 *)
  2.  
  3. type 'a susp
  4.  
  5. val delay : (unit -> 'a) -> 'a susp
  6. val force : 'a susp -> 'a
  7.  
  8. (* Type 'a susp is the type of lazily evaluated expressions with
  9.    result of type 'a.
  10.  
  11.    [delay (fn () => e)] creates a suspension for the expression e.
  12.    The first time the suspension is forced, the expression e will be
  13.    evaluated, and the result stored in the suspension.  All subsequent
  14.    forcing of the suspension will just return this result, so e is
  15.    evaluated at most once.  If the suspension is never forced, then e
  16.    is never evaluated.
  17.  
  18.    [force su] forces the suspension su and returns the result of the
  19.    expression e stored in the suspension.
  20. *)
  21.